package edu.faytechcc.csc.gui;

import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;



/**
 * Please describe what this class does here.
 *
 * CSC 251 0001
 * DATE:
 * @author Stephanie Mckenzie
 */
public class UserNameListPanel extends JPanel
{
    private DefaultListModel listModel;
    
    public UserNameListPanel()
    {
        this.addUserToList("Admin");
        JList userList = new JList(listModel);
        userList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        userList.setVisibleRowCount(10);
//        JScrollPane scrollPane = JScrollPane(userList);
        
        this.add(userList);
    }
    
    //puts the names in the user list
    private void setUserList(String[] users)
    {
        listModel = new DefaultListModel();
        for(int index = 0; index < users.length; index++)
        {
            this.addUserToList(users[index]);
        }
    }
    
    public void addUserToList(String name)
    {
        listModel.addElement(name);
    }
}

